//
//  PickerView.hpp
//  client
//
//  Created by DuanHongbo on 15/12/30.
//
//

#ifndef PickerView_hpp
#define PickerView_hpp

#include "cocos2d.h"
#include "ui/UILayout.h"
#include "ui/GUIExport.h"
#include "ui/UIListView.h"

NS_CC_BEGIN

namespace ui {
    
class PickerView : public ListView
{
public:
    enum class EventType
    {
        ON_PICKED_ITEM
    };
    
    typedef std::function<void(Ref*, PickerView::EventType,int)> ccPickerViewCallback;
public:
    static PickerView* create();
    
public:
    int getPickedIndex();
    void addEventListener(const ccPickerViewCallback& callback);
    void pickFirst();
    void pickLast();
    void pickTo(int index);
protected:
    virtual bool init() override;
    virtual void onEnter() override;
    void onAutoScellStop();
    void jumpToPicked();
private:
    ccPickerViewCallback _pickerViewCallback;
    int _pickedIndex;
};
    
}
NS_CC_END

#endif /* PickerView_hpp */
